
projectVM = new Vue({
	el: "#content",
	filters:{
		getWeather(e){
		var name = ''
			this.weatherList.forEach(item=>{
				if(item.itemSortOrder == e){
					name = item.itemText
				}
			})
			return name
		},
	},
	data: {
		roles:'',
		role:'',
		formData:'',
		currentUser:'',
		showForm:false,
		status:'RWP',
		doDate:'',
		list:[],
		companyName:'',
		companyCode:'',
		stationCode:'',
		weatherList:'',
		companyList:''
	},
	components: {
		personselect,
		processlog
	},
	
	created() {
		this.currentUser = JSON.parse(localStorage.getItem('neiosUser'))
		
		this.roles = this.currentUser.roles

		if(this.roles.indexOf('NEIOS_AREA_COMPANY')>=0){
			this.companyCode = this.currentUser.companyNewCode
			this.companyName = this.currentUser.companyName
			this.role = 'company'
		}
		else if(this.roles.indexOf('NEIOS_STATION')>=0){
			this.companyCode = this.currentUser.companyNewCode
			this.companyName = this.currentUser.companyName
			this.stationCode = this.currentUser.stationNewCode
			this.role = 'station'
		}
		else{
		
			this.role = 'total'
		}
		
		console.log(JSON.stringify(this.currentUser))
				let dictCodes = 'WEATHER';
		let dict = mui.neiosCommon.queryDict(dictCodes, (data) => {
					if (data != '') {
						this.weatherList = data.WEATHER;
						console.log(JSON.stringify(data.WEATHER))
					}
				})
		this.getNowdate()
		this.getCompany()
		
	}, 
	methods: {
		look(e){
			var that = this
			var param = {
				biztypeId:'RWP',
				newStationCode:e.newStationCode,
				singleDate:e.singleDate
			}							 
			mui.neiosRequst.httpRequst('/app/neiosControlDaily/queryDailyDetail', param,
				(data)=> {
			
					that.formData = data.detailList[0]
					
				
				
			
				},
				function(data) {
				
				})
			
				this.showForm = true
				
		},
			//选择停机类型
				showCompanyList(index){
					var that = this
					 let picker = new mui.PopPicker({
						 layer:1
					 })
					 picker.setData(this.companyList)
					  picker.show(function(e) {   //e 就是总数据的数组 显示picker
						that.companyCode = e[0].value
						that.companyName = e[0].text
					})
				
				},
		//获取当前时间
				getNowdate() {
					var date = new Date()
					var year = date.getFullYear()
					var month = date.getMonth()
					var day = date.getDate()
					var hour = date.getHours()
					var min = date.getMinutes()
					 var sec = date.getSeconds()
					month = month*1 + 1
					if (month.toString().length < 2) {
						month = '0' + month
					}
					if (day.toString().length < 2) {
						day = '0' + day
					}
					if (hour.toString().length < 2) {
						hour = '0' + hour
					}
					if (min.toString().length < 2) {
						min = '0' + min
					}
					if (sec.toString().length < 2) {
						sec = '0' + sec
					}
					this.doDate = year + '-' + month + '-' + day
				},
		//获取分公司列表
		getCompany(){
			var that = this
			var param = {
				orgType:'1',
				parentOrgCode:'',
				parentOrgType:''
			}							 
			mui.neiosRequst.httpRequst('/common/organization/getOrganizationListByType', param,
				(data)=> {
				if(data.code ==  0){	
					let arr = []
					data.data.forEach(item=>{
						arr.push({
							text:item.newOrgName,
							value:item.newOrgCode
						})
					})
					that.companyList = arr
				}
				else{
					mui.toast(data.msg)
				}

				},
				function(data) {
				
				})
		},
		//切换类型
		changeStatus(e){
			this.status = e
			this.getList()
		},
		//选择启动时间
		choosedoTime(){
			var that = this 
			var dtPicker = new mui.DtPicker({
				type: 'date'
			});
			dtPicker.show(function(selectItems) {
				that.doDate=selectItems.text
			})
		},
		//获取列表
		getList(){
			var that = this
			var param = {
				bizType:this.status,
				doDate:this.doDate,
				companyNewCode:this.companyCode,
				newStationCode:this.stationCode
			}							 
			console.log(JSON.stringify(param))
			mui.neiosRequst.httpRequst('/app/neiosControlDaily/queryDailyReport', param,
				(data)=> {
						var arr = data.detailList
						 arr.forEach(item=>{
							 this.weatherList.forEach(item1=>{
								 if(item.weather == item1.itemSortOrder){
									 item.weatherName = item1.itemText
								 }
							 })
						 })
						 that.list = arr
						if(data.detailList.length == 0){
							mui.toast('暂无数据')
						}
						},
						function(data) {
						mui.toast('查询失败')
						})
		},
	}

})